package com.atstudent.gmall.product.rpc;

import com.atstudent.gmall.common.result.Result;
import com.atstudent.gmall.product.biz.BaseCategoryBizService;
import com.atstudent.gmall.product.vo.CategoryVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


/**
 * service-product远程服务接口
 * @Author 薛有朋
 * @CreatDate 2024/11/29 21:23
 **/
@RestController
@RequestMapping(value = "/api/inner/product")
@Slf4j
public class BaseCategoryController {

    @Autowired
    private BaseCategoryBizService baseCategoryBizService;

    /**
     * 查询1、2、3级分类
     * @Author 薛有朋
     * @Date 2024/12/1 18:02
     **/
    @GetMapping(value = "/findAllCategoryTree")
    public Result<List<CategoryVo>> findAllCategoryTree(){
//        log.info("执行了...........");
//        try {
//            TimeUnit.SECONDS.sleep(2);
//        } catch (InterruptedException e) {
//            throw new RuntimeException(e);
//        }

        //List<CategoryVo> categoryVoList = baseCategoryBizService.findAllCategoryTree();
//        List<CategoryVo> categoryVoList = baseCategoryBizService.findAllLocalCategoryTree(); //本地缓存中查询
        //从Redis中查询  查到NUll的情况
        List<CategoryVo> categoryVoList = baseCategoryBizService.findAllCategoryTree();

        return Result.ok(categoryVoList);
    }
}
